﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication3
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void 打开窗口_Copy_Click(object sender, RoutedEventArgs e)
        {
            if(!_initialized)
            {
                //
                Label_message.Content = "请打开串口：";
                return;
            }

            Label_message.Content = "串口已打开！";
            double current_value = 0.0;
            double total_value = 70;
            double lower_value = -10;
            double temperature = (current_value - 4) / 16 * total_value + lower_value;
            Label_message.Content = "串口已打开！当前温度是" + temperature + "℃";

            double temp_limit = Convert.ToDouble(temperature _limit.Text);
            if (temperature >temp_limit )
            {
                label_warning.Content = "温度太高！";
            }
            else
            {
                label_warning.Content = "一切正常！";
            }

        }
    }
}
